#import "YLImageViewVC.h"
#import "YLImageView.h"

@interface YLImageViewVC ()

@property (weak, nonatomic) IBOutlet YLImageView *ivRound;
@property (weak, nonatomic) IBOutlet YLImageView *ivIcon;
@property (weak, nonatomic) IBOutlet YLImageView *ivIconSize;

@end

@implementation YLImageViewVC

// 下载图片
- (IBAction)onPressDownIcon:(id)sender {
    // 设置默认图
    self.ivIcon.imageHolder = @"placeholder";
    self.ivIcon.imageUrl = @"https://avatars0.githubusercontent.com/u/25520011?s=460&v=4";
}

// 下载图片并获取尺寸缩放
- (IBAction)onPressDownIconFitSize:(id)sender {
    __weak typeof(self) weakself = self;
    [self.ivIconSize dowload:@"https://avatars0.githubusercontent.com/u/25520011?s=460&v=4" callBack:^(BOOL isSucc, CGFloat ratio) {
        if (isSucc) {
           NSLog(@"图片尺寸:%f",ratio);
           CGRect frame = weakself.ivIconSize.frame;
           frame.size = CGSizeMake(frame.size.width, frame.size.width * ratio);
           weakself.ivIconSize.frame = frame;
        }
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // 下载头像
    self.ivRound.imageUrl = @"https://avatars0.githubusercontent.com/u/25520011?s=460&v=4";
}


@end
